package huaweiod.first;

import java.util.Scanner;

/**
 * 华为OD机试真题 Java 实现【数字加减游戏】【2022.11 Q4 新题】
 * 1 10 5 2
 * 1
 */
public class A_2023_48_NumberAddSubGame {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int s = in.nextInt();
        int t = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();

        int count = 0;
        int mod = 0;
        while (count <= Math.abs(b)) {
            if ((t - s + mod) % b == 0) {
                break;
            }
            if ((t - s - mod) % b == 0) {
                break;
            }
            mod = mod + a;
            count++;
        }
        System.out.println(count);
    }
}
